#!/usr/bin/env python
from random import random, randint

for _ in xrange(1000):
	l=randint(2,1000)
	cant=randint(1,min(50,l))
	print l
	print cant
	li=range(l)
	li2=[]
	for _ in range(cant):
		r=randint(1,len(li))
		li2.append(li[r-1])
		li[r-1]=li[-1]
		li=li[:-1]
	print ' '.join([str(i) for i in sorted(li2)])
print 0
